package com.baturu.vin.gm.transformer;

import com.baturu.kit.kit.function.SafeFunction;
import com.baturu.vin.dto.superEPC.SEPCCarTypeDTO;
import com.baturu.vin.dto.superEPC.SEPCCarTypeDetailDTO;
import com.baturu.vin.gm.dal.entity.OptionDescEntity;
import com.baturu.vin.gm.dto.GMVinModelDTO;
import com.google.common.collect.Lists;

/**
 * @Author: chenjiahao
 * @Time: 2019/11/1
 */
public class GMSEPCCarTypeTransformer {

    public static final SafeFunction<GMVinModelDTO, SEPCCarTypeDTO> VIN_TO_SEPC_CAR_TYPE = d ->
            SEPCCarTypeDTO.builder()
                    .brandName(d.getBrandName())
                    .showCarType(d.getBrandName()+" "+d.getCatalogCN()+" "+d.getYear())
                    .vinCode(d.getVinCode())
                    .btrId(d.getBtrId())
                    .carTypeDetailDTOList(Lists.newArrayList(
                            SEPCCarTypeDetailDTO.builder()
                            .desc("车辆主要信息")
                            .subValue(Lists.newArrayList(
                                    SEPCCarTypeDetailDTO.builder().desc("车架号").value(d.getVinCode()).build(),
                                    SEPCCarTypeDetailDTO.builder().desc("车系").value(d.getCatalogCN()).build(),
                                    SEPCCarTypeDetailDTO.builder().desc("年款").value(d.getYear()).build(),
                                    SEPCCarTypeDetailDTO.builder().desc("发动机").value(d.getEngine()+"-"+d.getEngineDesc()).build(),
                                    SEPCCarTypeDetailDTO.builder().desc("变速箱").value(d.getTransmission()+"-"+d.getTransmissionDesc()).build(),
                                    SEPCCarTypeDetailDTO.builder().desc("目录号").value(d.getCatalog()).build(),
                                    SEPCCarTypeDetailDTO.builder().desc("车型").value(d.getSeries()).build(),
                                    SEPCCarTypeDetailDTO.builder().desc("车身").value(d.getBody()).build()
                            )).build(),
                            SEPCCarTypeDetailDTO.builder()
                                    .desc("车辆配置信息")
                                    .subValue(d.getOptionDesc())
                                    .build()
                            ))
                    .build();

    public static final SafeFunction<OptionDescEntity, SEPCCarTypeDetailDTO> OPTION_CODE_DES = d ->
            SEPCCarTypeDetailDTO.builder()
                    .desc(d.getOptionCode())
                    .value(d.getDescriptionCn())
                    .build();
}
